<template>
  <div>
    <h2>送恋人/爱情鲜花</h2>
    <div
    class="home-recommend"
    v-for='item in items'
    :key='item.id'
    @click='clickItem(item.id)'
    >
      <div class="reco-left">
        <img v-lazy="item.pic" alt="" width="200px" />
      </div>
      <div class="reco-right">
        <h3 clsss="title">{{item.name}}</h3>
        <p class="desc">{{item.tags?item.tags:'暂无描述'}}</p>
        <div class="buttom">
          <span class="price"> ￥{{item.minPrice}} </span>
          <van-icon
            @click.stop='addCartHome(item)'
            name="gouwuche1"
            class-prefix="icon"
            class="xianhua"
          ></van-icon>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  methods: {
    clickItem (id) {
      this.$emit('clickItem', id)
    },
    addCartHome (item) {
      console.log(item)
      item = {
        ...item,
        num: 1,
        checked: true
      }
      this.$emit('addCartHome', item)
    }
  },
  props: {
    items: {
      type: Array,
      required: true
    }
  }
}
</script>

<style lang="scss" scoped>
h2{
    padding: 10px 0;
    text-align: center;
}
.home-recommend {
  display: flex;
  margin: 10px;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  .reco-right {
    flex: 1;
    padding: 15px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    .buttom {
      display: flex;
      .price {
        font-weight: bold;
        flex: 1;
      }
      .xianhua {
        background: #fb9998;
        padding: 3px;
        color: #fff;
        border-radius: 50%;
      }
    }
  }
}
</style>
